#ifndef ROLELISTWIDGET_H
#define ROLELISTWIDGET_H

#include <QTableWidget>
#include "bean/rolebean.h"
#include "QTableWidgetItem"
#include "QList"
#include "QByteArray"
#include "bean/citynode.h"
#include "utils/deviceutils.h"

class RoleTableWidget : public QTableWidget
{
    Q_OBJECT
private:
    QWidget *parent;
public:
    explicit RoleTableWidget(QWidget *parent = nullptr);
    ~RoleTableWidget();

    void creatNewRow(QString account = "", QString password = "", int roleIndex = 1);
    void init();
    bool isCreate = false;
    bool isCreateRoleFinish();
    bool getRoleBean(int row, RoleBean *roleBean);
    bool getAllRoleBeans(QList<RoleBean*> *allRoleBeans);
    void setData(QList<RoleBean> &roleBean);
    bool saveRoles2File();


    QList<RoleBean> readRolesByFile();

    enum colType{
            numType = 0,
            accountType = 1,
            passwordType = 2,
            roleNameType = 3,
            deleteType = 4
    };

signals:
    void logEvent(QString log);
};

#endif // ROLELISTWIDGET_H
